<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Administrador de Jogos</title>
</h:head>
<h:body>
	<h:form>
		<h:panelGrid columns="2">
			<h:panelGroup>
				<h:messages showDetail="true" />
				<h:panelGrid columns="2">
					<h:outputLabel value="Data do Jogo" for="campoData" />
					<h:inputText value="#{futebolBean.partida.dataJogo}" id="campoData"
						label="Data do Jogo" required="true">
						<f:convertDateTime pattern="dd/MM/yyyy" locale="pt_BR" />
						<f:validator validatorId="com.exercicios.futebol.validator.FutureDate"/>
					</h:inputText>


					<h4>Time da Casa</h4>
					<h:outputLabel />

					<h:outputLabel value="Nome do Time" for="campoNomeCasa" />
					<h:inputText value="#{futebolBean.partida.nomeCasa}"
						id="campoNomeCasa" label="Tima da Casa" required="true">
						<f:validateLength minimum="5" />
					</h:inputText>


					<h:outputLabel value="Qtd. Gols" for="campoGolCasa" />
					<h:inputText value="#{futebolBean.partida.golCasa}"
						id="campoGolCasa" label="Gols do time da casa" required="true">
						<f:validateLongRange minimum="0" maximum="99" />
					</h:inputText>


					<h4>Time Visitante</h4>
					<h:outputLabel />

					<h:outputLabel value="Nome do Time" for="campoNomeVisitante" />
					<h:inputText value="#{futebolBean.partida.nomeVisitante}"
						id="campoNomeVisitante" label="Time Visitante" required="true">
						<f:validateLength minimum="5" />
					</h:inputText>


					<h:outputLabel value="Qtd. Gols" for="campoGolVisitante" />
					<h:inputText value="#{futebolBean.partida.golVisitante}"
						id="campoGolVisitante" label="Gols do time visitante"
						required="true">
						<f:validateLongRange minimum="0" maximum="99" />
					</h:inputText>


					<h4>Bilheteria</h4>
					<h:outputLabel />

					<h:outputLabel value="Valor" for="campoBilheteria" />
					<h:inputText value="#{futebolBean.partida.valor}"
						id="campoBilheteria" label="Bilheteria">
						<f:convertNumber minFractionDigits="2" locale="pt_BR" />
						<f:converter converterId="com.exercicios.futebol.converter.NumericValue"/>
						<f:validateDoubleRange minimum="0" />
					</h:inputText>


					<h:outputLabel />
					<h:panelGroup>
					<h:selectOneMenu label="RamoAtividade" value="#{futebolBean.ramoAtividade}" required="true" >
						<f:selectItem noSelectionOption="true" itemLabel="Selecione" />
						<f:selectItems value="#{futebolBean.ramosAtividade}" var="ramo" 
						itemValue="#{ramo}"
						itemLabel="#{ramo.descricao}" />
					</h:selectOneMenu>
						<h:commandButton value="Salvar"
							action="#{futebolBean.adicionarPartida}" />
							<h:commandButton value="Limpar lista" action="#{futebolBean.limpar}" immediate="true"/>
					</h:panelGroup>

				</h:panelGrid>
			</h:panelGroup>
			<h:dataTable value="#{futebolBean.partidas}" var="partida" border="1"
				rendered="#{not empty futebolBean.partidas}">
				<h:column>
					<f:facet name="header">
						Data da Partida
					</f:facet>

					<h:outputText value="#{partida.dataJogo}">
						<f:convertDateTime pattern="dd/MM/yy" />
					</h:outputText>
				</h:column>
				<h:column>
					<f:facet name="header">
						Resultado
					</f:facet>

					<h:outputText
						value="#{partida.nomeCasa} #{partida.golCasa}  X  #{partida.golVisitante}  #{partida.nomeVisitante}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						Arrecadação
					</f:facet>

					<h:outputText value="#{partida.valor}">
						<f:converter converterId="com.exercicios.futebol.converter.NumericValue"/>
						<f:convertNumber type="currency" currencySymbol="R$"
							locale="pt_BR" />
					</h:outputText>
				</h:column>
			</h:dataTable>
		</h:panelGrid>
	</h:form>
</h:body>
</html>